Skip to content

Conversation

hero78119
Copy link
Collaborator

@hero78119 hero78119 commented Apr 29, 2025

To close issue #632
named io as debug_println in guest program debug build, assuming no "println!" use case in guest program.

Design rationales

In debug build, we extend stack address a bit to cover a reserved 256k for io. This extra reserved space also reflect in linker script, so the write to this region wont got any complaints from either elf or riscv emulator

Besides, this PR also fix a previous problem where meaningful symbol in bss/sbss section will be skip due to their value are 0. We need to reserve and padding to cover them, since those might be some static variables initialized with 0 or uninitialized. Without do it, emulator will also complain regions is not writable.

Change scope

  • cleanup previois workaround in guest program for io
  • extend stack address for io consistency check during debug build
  • refactor load_elf bss/sbss padding issue.
  • e2e command also shows io result.
  • respect profile in guest program examples compilation.

Example testing command:

An guest program with IO

# release run
cargo run --release --features sanity-check --package ceno_zkvm --bin e2e  -- --platform=ceno --hints=10 --public-io=4191 examples/target/riscv32im-ceno-zkvm-elf/release/examples/ceno_rt_io

# debug run
cargo run --features sanity-check --package ceno_zkvm --bin e2e  -- --platform=ceno --hints=10 --public-io=4191 examples/target/riscv32im-ceno-zkvm-elf/debug/examples/ceno_rt_io

@hero78119 hero78119 changed the title Feat/io debug only support guest program "println!" in e2e flow Apr 29, 2025
@hero78119 hero78119 marked this pull request as draft April 29, 2025 02:37
@hero78119 hero78119 marked this pull request as ready for review April 29, 2025 09:10
@hero78119 hero78119 requested a review from lightsing May 6, 2025 02:16
Copy link
Member

@lightsing lightsing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, so the stdout still not supported. native println! or eprintln! won't be collected.
We may need this later.

@hero78119
Copy link
Collaborator Author

hero78119 commented May 6, 2025

I see, so the stdout still not supported. native println! or eprintln! won't be collected. We may need this later.

Yeah I intent to not support println! at this moment since I feel io should only for debug purpose. In release mode guest should never incurr io. Application constraint assert still work as expected.

We can extend println! once the use case comes 😄

@hero78119 hero78119 added this pull request to the merge queue May 6, 2025
// See git history for an attempt to do this.
let is_release = std::env::var("PROFILE").unwrap() == "release";
let mut args = vec!["build", "--examples", "--target-dir", "target"];
if is_release {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also resolved asked question in original issue #632 (comment)

Merged via the queue into scroll-tech:master with commit 681a84c May 6, 2025
4 checks passed
@hero78119 hero78119 deleted the feat/io_debug_only branch May 6, 2025 09:38
@hero78119 hero78119 mentioned this pull request May 6, 2025
dreamATD pushed a commit that referenced this pull request May 7, 2025
To close issue #632
named io as `debug_println` in guest program debug build, assuming no
"println!" use case in guest program.

In debug build, we extend stack address a bit to cover a reserved 256k
for io. This extra reserved space also reflect in linker script, so the
write to this region wont got any complaints from either elf or riscv
emulator

Besides, this PR also fix a previous problem where meaningful symbol in
bss/sbss section will be skip due to their value are 0. We need to
reserve and padding to cover them, since those might be some static
variables initialized with 0 or uninitialized. Without do it, emulator
will also complain regions is not writable.

- cleanup previois workaround in guest program for io
- extend stack address for io consistency check during debug build
- refactor `load_elf` bss/sbss padding issue.
- e2e command also shows io result.
- respect profile in guest program examples compilation.

An guest program with IO

```bash
cargo run --release --features sanity-check --package ceno_zkvm --bin e2e  -- --platform=ceno --hints=10 --public-io=4191 examples/target/riscv32im-ceno-zkvm-elf/release/examples/ceno_rt_io

cargo run --features sanity-check --package ceno_zkvm --bin e2e  -- --platform=ceno --hints=10 --public-io=4191 examples/target/riscv32im-ceno-zkvm-elf/debug/examples/ceno_rt_io
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants